import moment from "moment";
import { Tag, Button, Switch } from "antd";
//分类column
export const dictColumn = ({ handleToData }) => {
  const columns = [
    {
      align: "center",
      title: "字典类型",
      dataIndex: "dictType",
      render: (type) => {
        return <Tag color="warning">{type}</Tag>;
      },
    },
    {
      align: "center",
      title: "字典名称",
      dataIndex: "dictName",
    },
    {
      align: "center",
      title: "备注",
      dataIndex: "comment",
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
    {
      align: "center",
      title: "操作",
      render: (row) => {
        return (
          <Button
            style={{ background: "#13ce66", color: "#fff", border: "none" }}
            onClick={() => handleToData(row.id)}
          >
            列表
          </Button>
        );
      },
    },
  ];

  return columns;
};

export const dictDataColumn = () => {
  const columns = [
    {
      align: "center",
      title: "字典类型",
      dataIndex: "dictType",
      render: (type) => {
        return <Tag color="warning">{type}</Tag>;
      },
    },
    {
      align: "center",
      title: "字典名称",
      dataIndex: "dictName",
    },
    {
      align: "center",
      title: "枚举名称",
      dataIndex: "enumText",
    },
    {
      align: "center",
      title: "枚举code",
      dataIndex: "enumCode",
    },
  ];
  return columns;
};

export const talkGroupColumn = ({ handleToData }) => {
  const columns = [
    {
      align: "center",
      title: "名称",
      dataIndex: "groupName",
      render: (type) => {
        return <Tag color="blue">{type}</Tag>;
      },
    },
    {
      align: "center",
      title: "状态",
      dataIndex: "status",
      render: (status) => {
        return status === 1 ? (
          <Tag color="blue">正常</Tag>
        ) : (
          <Tag color="blue">禁用</Tag>
        );
      },
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
    {
      align: "center",
      title: "操作",
      render: (row) => {
        return (
          <Button
            style={{ background: "#13ce66", color: "#fff", border: "none" }}
            onClick={() => handleToData(row.groupType)}
          >
            列表
          </Button>
        );
      },
    },
  ];

  return columns;
};

export const talkColumn = ({ handleGroupName }) => {
  const columns = [
    {
      align: "center",
      title: "圈子名称",
      dataIndex: "groupId",
      render: (groupId) => {
        return <Tag color="warning">{handleGroupName(groupId)}</Tag>;
      },
    },
    {
      align: "center",
      title: "评论`用户",
      dataIndex: "userInfo",
      render: (userInfo) => {
        return userInfo.nickname;
      },
    },
    {
      align: "center",
      title: "头像",
      dataIndex: "userInfo",
      render: (userInfo) => {
        return (
          <img
            src={userInfo.avatar}
            style={{ width: "50px", height: "50px", borderRadius: "50%" }}
          ></img>
        );
      },
    },
    {
      align: "center",
      title: "会话id",
      dataIndex: "forumId",
    },
    {
      align: "center",
      title: "留言内容",
      dataIndex: "content",
      render: (content) => {
        return <div dangerouslySetInnerHTML={{ __html: content }} />;
      },
    },
    {
      align: "center",
      title: "回复消息Id",
      dataIndex: "replyId",
    },
    {
      align: "center",
      title: "是否顶层消息",
      dataIndex: "istop",
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
  ];
  return columns;
};

// 导航类型列表
export const navColumn = ({ handleToData }) => {
  const columns = [
    {
      align: "center",
      title: "分类名称",
      dataIndex: "name",
    },
    {
      title: "排序",
      dataIndex: "order",
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
    {
      align: "center",
      title: "操作",
      render: (row) => {
        return (
          <Button
            style={{ background: "#13ce66", color: "#fff", border: "none" }}
            onClick={() => handleToData(row.id)}
          >
            列表
          </Button>
        );
      },
    },
  ];
  return columns;
};

// 导航列表

export const navDataColumn = ({ handleOpenEditVisible,handleSwitchStatus }) => {
  const columns = [
    {
      align: "center",
      dataIndex: "logo",
      title: "网址logo",
      render: (logo) => {
        return <img src={logo} style={{ width: "50px", height: "50px" }}></img>;
      },
    },
    {
      align: "center",
      dataIndex: "title",
      title: "网址标题",
    },
    {
      align: "center",
      dataIndex: "ip_address",
      title: "网址导航",
      render: (ip) => {
        return (
          <a href={ip} target="_blank">
            {ip}
          </a>
        );
      },
    },
    {
      align: "center",
      dataIndex: "description",
      title: "网址描述",
    },
    {
      align: "center",
      title: "状态",
      render: (row) => {
        return (
          <Switch
            checked={row.status === 1 ? true : false}
            onChange={() => handleSwitchStatus(row)}
          />
        );
      },
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
    {
      align: "center",
      title: "操作",
      render: (row) => {
        return (
          <div>
            <Button
              type="primary"
              style={{ marginLeft: "10px" }}
              size="small"
              onClick={() => handleOpenEditVisible(row)}
            >
              编辑
            </Button>
          </div>
        );
      },
    },
  ];
  return columns;
};

// 友情链接

export const friendLinkColumn = ({
  handleOpenEditVisible,
  handleSwitchStatus,
}) => {
  const columns = [
    {
      align: "center",
      title: "网站图标",
      dataIndex: "icon",
      render: (icon) => {
        return <img src={icon} style={{ width: "50px", height: "50px" }}></img>;
      },
    },
    {
      align: "center",
      title: "网站名称",
      dataIndex: "name",
    },
    {
      align: "center",
      title: "网站描述",
      dataIndex: "description",
    },
    {
      align: "center",
      title: "网站地址",
      dataIndex: "ip_address",
      render: (ip) => {
        return (
          <a href={ip} target="_blank">
            {ip}
          </a>
        );
      },
    },
    {
      align: "center",
      title: "状态",
      render: (row) => {
        return (
          <Switch
            checked={row.status === 1 ? true : false}
            onChange={() => handleSwitchStatus(row)}
          />
        );
      },
    },
    {
      align: "center",
      title: "创建时间",
      render: (row) => {
        if (!row.createTime) {
          return "--";
        } else {
          return moment(parseInt(row.createTime)).format("YYYY-MM-DD HH:mm:ss");
        }
      },
    },
    {
      align: "center",
      title: "操作",
      render: (row) => {
        return (
          <div>
            <Button
              type="primary"
              style={{ marginLeft: "10px" }}
              size="small"
              onClick={() => handleOpenEditVisible(row)}
            >
              编辑
            </Button>
          </div>
        );
      },
    },
  ];
  return columns;
};
